﻿using FirstFloor.ModernUI.Presentation;
using ICAM.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ICAM
{
    /// <summary>
    /// Log.xaml 的交互逻辑
    /// </summary>
    public partial class Log : Window, INotifyPropertyChanged
    {
        public Log()
        {
            InitializeComponent();
            this.DataContext = this;
            InitData();
        }


        private ObservableCollection<OperationLog> _operationLogInfos = new ObservableCollection<OperationLog>();

        public ObservableCollection<OperationLog> OperationLogInfos
        {
            get { return this._operationLogInfos; }
            set {
                this._operationLogInfos = value;
                OnPropertyChanged("OperationLogInfos");
            }
        }

        private void InitData()
        {
            OperationLog operationLog1 = new OperationLog() {
                OperateType = "账号登录",
                OperateTime = "2019年8月9日 23:34",
                OperateUserName = "李大强",
                PhoneNo="133 7788 7788"
            };
            OperationLog operationLog2 = new OperationLog()
            {
                OperateType = "账号退出",
                OperateTime = "2019年8月9日 23:34",
                OperateUserName = "李大强",
                PhoneNo = "133 7788 7788"
            };
            OperationLog operationLog3 = new OperationLog()
            {
                OperateType = "账号登录",
                OperateTime = "2019年8月9日 23:34",
                OperateUserName = "陈丽丽",
                PhoneNo = "133 7788 7788"
            };
            OperationLog operationLog4 = new OperationLog()
            {
                OperateType = "账号登录",
                OperateTime = "2019年8月9日 23:34",
                OperateUserName = "陈丽丽",
                PhoneNo = "133 7788 7788"
            };
            OperationLog operationLog5 = new OperationLog()
            {
                OperateType = "账号登录",
                OperateTime = "2019年8月9日 23:34",
                OperateUserName = "陈丽丽",
                PhoneNo = "133 7788 7788"
            };

            OperationLogInfos.Add(operationLog1);
            OperationLogInfos.Add(operationLog2);
            OperationLogInfos.Add(operationLog3);
            OperationLogInfos.Add(operationLog4);
            OperationLogInfos.Add(operationLog5);

        }
        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Raises the PropertyChanged event.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        protected virtual void OnPropertyChanged(string propertyName)
        {
            var handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
